<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>11.说明data为啥是函数</title>
    </head>
    <body>
        <script type="text/javascript" >
            // 假设下面的data是组件中的data，data写成对象
            /* let data = {
                a:1,
                b:2
            }

            data.a = 9
            console.log(data.a)
            console.log(data.a) */

            /* *************************************** */
            // 假设下面的data是组件中的data，data写函数
            let data = function(){
                return {
                    a:1,
                    b:2
                }
            }

            /* let myA = data().a
            myA = 9
            console.log(myA)

            let myA2 = data().a
            console.log(myA2) */

            console.log(data().a)
            console.log(data().a)
            console.log(data() === data())
        </script>
    </body>
</html>